﻿using System;

namespace enyo
{
    /// <summary>
    /// A control that shows web content with built-in scroller.
    /// </summary>
    public class WebView : Control
    {
        /// <summary>
        /// Page identifier, used to open new WebViews for new window requests.
        /// </summary>
        public string Identifier { get; set; }

        /// <summary>
        /// URL for page, updated as user navigates. Relative URLs are not allowed.
        /// </summary>
        public string Url { get; set; }

        /// <summary>
        /// Smallest font size shown on the page, used to stop text from becoming unreadable.
        /// </summary>
        public int MinFontSize { get; set; }

        /// <summary>
        /// If true, allows page to run JavaScript.
        /// </summary>
        public bool EnableJavascript { get; set; }

        /// <summary>
        /// If false, allows page to request that new windows be opened.
        /// </summary>
        public bool BlockPopups { get; set; }

        /// <summary>
        /// If true, allows WebView to accept cookies from server.
        /// </summary>
        public bool AcceptCookies { get; set; }

        /// <summary>
        /// Array of URL redirections
        /// </summary>
        public Redirect[] Redirects { get; set; }

        /// <summary>
        /// The network interface.
        /// </summary>
        public string NetworkInterface { get; set; }//TODO:type correct?

        /// <summary>
        /// If true, page ignores viewport-related meta tags.
        /// </summary>
        public bool IgnoreMetaTags { get; set; }

        /// <summary>
        /// If true (default), WebKit will cache the plugin when the node is hidden.
        /// If your app explicitly destroys the plugin outside the app lifecycle, you must set this to false.
        /// </summary>
        public bool CacheAdapter { get; set; }


        /*TODO:To be refined
        onMousehold: ""
        onResized: ""
        onPageTitleChanged: ""
        onUrlRedirected: ""
        onSingleTap: ""
        onLoadStarted: ""
        onLoadProgress: ""
        onLoadStopped: ""
        onLoadComplete: ""
        onFileLoad: ""
        onAlertDialog: ""
        onConfirmDialog: ""
        onPromptDialog: ""
        onSSLConfirmDialog: ""
        onUserPasswordDialog: ""
        onNewPage: ""
        onPrint: ""
        onEditorFocusChanged: ""
        onError: ""
        onDisconnected: ""
        */

        /// <summary>
        /// Accepts the current dialog.
        /// </summary>
        public void AcceptDialog()
        {
        }

        /// <summary>
        /// Cancels the current dialog.
        /// </summary>
        public void CancelDialog()
        {
        }

        public void ClearCache()
        {
        }

        public void ClearCookies()
        {
        }

        public void ClearHistory()
        {
        }

        /// <summary>
        /// Deletes an image from the file system.
        /// </summary>
        /// <param name="path"></param>
        public void DeleteImage(string path)
        {
        }


        public void Disconnect()
        {
        }

        /// <summary>
        /// Generates an icon from an image in the file system. Only works with PNG files.
        /// </summary>

        public void GenerateIconFromFile(string path, string iconPath, int left, int top, int width, int height)
        {
        }


        public void GoBack()
        {
        }

        public void GoForward()
        {
        }

        /// <summary>
        /// If in an editable field, inserts a string at the current cursor position.
        /// </summary>
        /// <param name="str"></param>
        public void InsertStringAtCursor(string str)
        {
        }

        /// <summary>
        /// Shows the print dialog to print the current page.
        /// </summary>        
        public void PrintFrame(string name, int jobId, int width, int height, int dpi, int landscape, int reverseOrder)
        {
        }

        public void ReloadPage()
        {
        }

        /// <summary>
        /// Resizes an image in the file system.
        /// </summary>
        /// <param name="fromPath"></param>
        /// <param name="toPath"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public void ResizeImage(string fromPath, string toPath, int width, int height)
        {
        }

        /// <summary>
        /// Saves to the file system the image at the specified position.
        /// </summary>
        /// <param name="Left"></param>
        /// <param name="top"></param>
        /// <param name="directory"></param>
        /// <param name="callback"></param>
        public void SaveImageAtPoint(int Left, int top, string directory, Delegate callback)
        {
        }

        /// <summary>
        /// Responds to the current dialog.
        /// </summary>
        /// <param name="response"></param>
        public void SendDialogResponse(object response)//TODO:Type??
        {
        }

        public void StopLoad()
        {
        }
    }

    public class Redirect
    {
        public System.Text.RegularExpression Regexp;
        public string Cookie;
        public bool Enable;
    }
}
